package com.xidian.zhiancloud.controller.emergencyManagement;

import com.xidian.zhiancloud.controller.base.BaseController;
import com.xidian.zhiancloud.dto.ResultDTO;
import com.xidian.zhiancloud.enums.GeneralResponseEnums;
import com.xidian.zhiancloud.model.WarehouseOut;
import com.xidian.zhiancloud.model.Warehousing;
import com.xidian.zhiancloud.service.emergencyManagement.WarehouseOutService;
import com.xidian.zhiancloud.service.emergencyManagement.WarehousingService;
import com.xidian.zhiancloud.vo.emergencyManagement.WarehouseOutVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 应急管理 应急物资管理接口-出库
 */
@RestController
@RequestMapping("/WarehouseOut")
public class WarehouseOutController extends BaseController {
    @Autowired
    private WarehouseOutService warehouseOutService;

    /**
     * 增加出库记录
     *
     * @param warehouseOut 出库对象
     * @return 返回是否添加成功
     */
    @PostMapping("/add")
    public ResultDTO<Boolean> add(WarehouseOut warehouseOut) {
        warehouseOut.setCreateTime(new Date(System.currentTimeMillis()));
        warehouseOut.setCreatorId(getSessionUserid());
        warehouseOut.setCompanyId(getSessionUserCompanyId());
        Boolean res = warehouseOutService.add(warehouseOut);
        return ResultDTO.successOf(res, GeneralResponseEnums.SUCCESS);
    }

    /**
     * 获取出库记录
     * @param id 出库记录id
     * @return 出库对象
     */
    @GetMapping("/getWarehouseOut")
    public  ResultDTO<List<WarehouseOutVO>> getWarehouseOut(@RequestParam("id") Long id){
        return ResultDTO.successOf(warehouseOutService.getWarehouseOut(id),GeneralResponseEnums.SUCCESS);
    }
}
